    package cn.wit.utils.response;

    import com.fasterxml.jackson.databind.ObjectMapper;
    import lombok.Data;

    import java.io.Serializable;

    /**
     * 商城自定义响应模型
     */
    @Data
    public class Result implements Serializable {
        // 定义jackson对象
        private static final ObjectMapper MAPPER = new ObjectMapper();

        // 响应业务状态
        private Integer status;

        // 响应消息
        private String msg;

        private static final Integer okcode=200;
        private static final Integer errorcode=500;

        // 响应中的数据
        private Object data;

        public static Result build(Integer status, String msg, Object data) {
            return new Result(status, msg, data);
        }
        public static Result error(String msg) {
            return new Result(500, msg, null);
        }

        public static Result ok(Object data) {
            return new Result(data);
        }

        public static Result ok() {
            return new Result(null);
        }

        public Result() {

        }

        public static Result build(Integer status, String msg) {
            return new Result(status, msg, null);
        }

        public Result(Integer status, String msg, Object data) {
            this.status = status;
            this.msg = msg;
            this.data = data;
        }

        public Result(Object data) {
            this.status = okcode;
            this.msg = "OK";
            this.data = data;
        }
    }
